package org.example.config;

import org.example.scope.ThreadLocalScope;
import org.springframework.beans.factory.config.CustomScopeConfigurer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

/**
 * Spring配置类
 * 启用组件扫描，自动发现和注册带有@Component注解的Bean
 * 并注册自定义作用域
 */
@Configuration
@ComponentScan(basePackages = "org.example")
public class AppConfig {
    
    /**
     * 注册自定义的ThreadLocal作用域
     */
    @Bean
    public static CustomScopeConfigurer customScopeConfigurer() {
        CustomScopeConfigurer configurer = new CustomScopeConfigurer();
        configurer.addScope("thread", new ThreadLocalScope());
        return configurer;
    }
} 